Total Complexity | 5 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import execa from 'execa' |
||
4 | |||
5 | class Expose extends Tool { |
||
6 | alias = 'expose' |
||
7 | name = 'Beyondcode Expose' |
||
8 | |||
9 | /** |
||
10 | * Install the app. |
||
11 | */ |
||
12 | install = async (): Promise<boolean> => { |
||
13 | if (await this.isInstalled()) { |
||
14 | warning(`${this.name} already is installed. Execute it by running ${this.alias}`) |
||
15 | return false |
||
16 | } |
||
17 | |||
18 | info(`Installing ${this.name} using Composer...`) |
||
19 | |||
20 | await execa('composer', ['global', 'require', 'beyondcode/expose']) |
||
21 | |||
22 | success(`Successfully installed ${this.name}.`) |
||
23 | |||
24 | return true |
||
25 | } |
||
26 | |||
27 | |||
28 | /** |
||
29 | * Uninstall the app. |
||
30 | */ |
||
31 | uninstall = async (): Promise<boolean> => { |
||
32 | if (!(await this.isInstalled())) { |
||
33 | error(`${this.name} is not installed.`) |
||
34 | return false |
||
35 | } |
||
36 | |||
37 | info(`Uninstalling ${this.name} using Composer...`) |
||
38 | |||
39 | await execa('composer', ['global', 'remove', 'beyondcode/expose']) |
||
40 | |||
41 | success(`Successfully uninstalled ${this.name}.`) |
||
42 | |||
43 | return true |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Check if the app is already installed.. |
||
48 | */ |
||
49 | isInstalled = async (): Promise<boolean> => { |
||
50 | const {stdout} = await execa('composer', ['global', 'show', '-i']) |
||
51 | return stdout.includes('beyondcode/expose') |
||
52 | } |
||
55 | export default Expose |